﻿@{
	ViewBag.Title = "简历筛选";
}

<script src="~/lib/vue/dist/vue.global.js"></script>
<script src="~/lib/axios/dist/axios.js"></script>
<link href="~/lib/element-plus/dist/index.css" rel="stylesheet" />
<script src="~/lib/element-plus/dist/index.full.js"></script>

<div id="app">

		<h3>您正在做的业务是：人力资源--招聘管理--简历管理--简历筛选 </h3>
		@* <input type="button" value="开始" v-on:click="Chaxun()" /> *@
	<el-button type="primary" v-on:click="Chaxun()">查询</el-button>
     	<table :model="khbh" class="tableEdit">
		<tr>
			<th>职位分类</th>
			<td>

				<el-select v-model="khbh.MajorKindName" :disabled="zwxlk" placeholder="请选择" v-on:change="CMName()">
					<el-option v-for="option in zwfl"
							   :key="option.majorKindId"
							   :label="option.majorKindName"
							   :value="option.majorKindName">
					</el-option>
				</el-select>

			</td>
			<th>职位名称</th>
			<td>

				<el-select v-model="khbh.MajorName" :disabled="zwmcxlk" placeholder="请选择">
					<el-option v-for="option in zwmc"
							   :key="option.majorId"
							   :label="option.majorName"
							   :value="option.majorName">
					</el-option>
				</el-select>
		</tr>
	
		<tr>
			<th>请输入关键字</th>
			<td colspan="10">
				<textarea v-model="khbh.HumanName" style="resize: none;"></textarea>
			</td>
		</tr>
		<tr>
			<th>请输入登记时间</th>
			<td colspan="10">
				<el-date-picker v-model="khbh.deadline" type="datetime" style="width: 200px;"></el-date-picker>至<el-date-picker v-model="khbh.shijian" type="datetime" style="width: 200px;"></el-date-picker>(YYY-MM-DD)
			</td>
		</tr>
	</table>



	<div v-if="jlsx">
		<!-- 表格内容 -->
		<el-table :data="tableData"  style="width: 100%">
			<!-- 表格列 -->
			<el-table-column prop="humanName" label="姓名"></el-table-column>
			<el-table-column prop="humanAge" label="年龄"></el-table-column>
			<el-table-column prop="humanMajorKindName" label="职位编号"></el-table-column>
			<el-table-column prop="hunmaMajorName" label="职位名称"></el-table-column>
			<el-table-column prop="checkStatus" label="复核状态"></el-table-column>

			<el-table-column label="职位信息">
				<!-- 自定义操作列 -->
				<template #default="scope">
					<el-button link type="primary" size="small" v-on:click="update(scope.row)">{{shengqing}}</el-button>
				</template>
			</el-table-column>
		</el-table>
		
	</div>

</div>


<script type="text/javascript">
	const { createApp, ref, reactive, onMounted, computed, onBeforeUnmount, useRoute } = Vue
	var app = createApp({
		setup() {

			let tableData = ref([]);

			//简历筛选表
			let jlsx = ref(true);

			let shengqing = ref("申请该职位");

			const khbh = ref({
				FirstKindName: "",
				SecondKindName: "",
				ThirdKindName: "",
				ZhaoPin: "",
				HumanAmount: "",
				Register: "哈哈哈",
				deadline: "",
				MajorName: "",
				EngageRequired: "",
				MajorDescribe: "",
				MajorKindName: "",
				shijian: "",
				HumanName: ""
			})

			// 职位分类编号下拉框选项数据
			let zwfl = ref("");
			// 职位分类编号下拉框绑定值
			function zwfltKindOptions() {

				axios.get('/EMR/SelectCMK')
					.then(res => {
						//console.info(res)
						zwfl.value = res.data;
					})
					.catch(err => {
						console.info(res);
					})
			}

			//存职位编号
			let zwmc = ref("");
			function CMName() {
				if (!khbh.value.MajorKindName) {
					return;
				}
				axios.get("/EMR/SelectCM2Name?name=" + encodeURIComponent(khbh.value.MajorKindName))
					.then(function (response) {
						zwmc.value = response.data;

						const previousMajorName = khbh.value.MajorName;
						const foundMajor = zwmc.value.find(option => option.majorName === previousMajorName);
						if (foundMajor) {
							khbh.value.MajorName = foundMajor.majorName; // Update MajorName if necessary
							khbh.value.MajorId = foundMajor.majorId; // Assign MajorId
						}
					})
					.catch(function (error) {
						console.error(error);
					});
			}

			//窗体加载分页
			function fill() {
				if (Panduan.value == 1) {
					//传过来的值是1就查所有简历
					axios.get('/ER/SelectER')
						.then(res => {
							//console.info(res)
							tableData.value = res.data;
						})
						.catch(err => {
							console.info(res);
						})
				} else if (Panduan.value == 2) {
					axios.get('/ER/GetERName?name=' + '已复核')
						.then(res => {
							//console.info(res)
							tableData.value = res.data;
						})
						.catch(err => {
							console.info(res);
						})
				}
			};

			//多条件查询
			function Chaxun() {
				const startDate = new Date(this.khbh.shijian).toISOString(); // 转换为 ISO 格式的字符串
				const endDate = new Date(this.khbh.deadline).toISOString();
				if (endDate > startDate) {
					alert("起始时间不可大于结束时间!!");
					return;
				};
				if (Panduan.value == 1) {
					//如果条件全空则查全部
					if (!this.khbh.MajorKindName && !this.khbh.MajorName && !this.khbh.HumanName && !this.khbh.deadline && !this.khbh.shijian) {
						fill();
					} else {
						axios.get('/ER/SelectTiaojian?humanName=' + khbh.value.HumanName + "&hunmaMajorName=" + this.khbh.MajorName + "&humanMajorKindName=" + this.khbh.MajorKindName + "&startDate=" + endDate + "&endDate=" + startDate)
							.then(res => {
								//console.info(res)
								tableData.value = res.data;

							})
							.catch(err => {
								console.info(res);
							})
					}
				} else if (Panduan.value == 2) {
					axios.get('/ER/SelectYouxiaoTiaojian?humanName=' + khbh.value.HumanName + "&hunmaMajorName=" + this.khbh.MajorName + "&humanMajorKindName=" + this.khbh.MajorKindName + "&startDate=" + endDate + "&endDate=" + startDate + "&passPassComment=" + "已复核")
						.then(res => {
							//console.info(res)
							tableData.value = res.data;
						})
						.catch(err => {
							console.info(res);
						})
				}
			}



			//修改
			function update(row) {

				let queryString = '?';
				// 遍历row对象的每个属性，并将其添加到查询字符串中
				for (let key in row) {
					if (row.hasOwnProperty(key)) {
						queryString += encodeURIComponent(key) + '=' + encodeURIComponent(row[key]) + '&';
					}
				}
				// 去除最后一个 '&'
				queryString = queryString.slice(0, -1);
				// 构建完整的跳转 URL
				let destination = '/ER/ER' + queryString;
				// 跳转到新页面
				window.location.href = destination;

				//let queryString = '?';
				//// 只选择您想传递的属性
				//const paramsToPass = ['humanName', 'humanAge'];
				//paramsToPass.forEach(param => {
				//	if (row.hasOwnProperty(param)) {
				//		queryString += encodeURIComponent(param) + '=' + encodeURIComponent(row[param]) + '&';
				//	}
				//});
				//// 去除最后一个 '&'
				//queryString = queryString.slice(0, -1);
				//// 构建完整的跳转 URL
				//let destination = '/Customization/RegJLDJ' + queryString;
				//// 跳转到新页面
				//window.location.href = destination;

			}

			const Panduan = ref('');

			onMounted(() => {

				//const iframeSrc = document.getElementById('iframeView').src;
				//const paramValue = iframeSrc.split('/').pop(); // 获取路径中的最后一部分作为参数值
				//param.value = paramValue;
				//console.log('参数为:', param.value);

				function getQueryParam(name) {
					const urlParams = new URLSearchParams(window.location.search);
					return urlParams.get(name);
				}
				const param = getQueryParam('param');
				if (param) {
					Panduan.value = param;
				}
				console.log('参数为:', Panduan.value);

				if (Panduan.value == 2) {
					shengqing.value = "查看详细信息";
				}

				fill();

			});


			zwfltKindOptions();
			return {
				Panduan,
				tableData,
				fill,
				update,
				jlsx,
				khbh,
				Chaxun,
				zwfl,
				zwfltKindOptions,
				zwmc,
				CMName,
				shengqing


			}
		}
	});
	app.use(ElementPlus)
	app.mount('#app')

</script>

<style scoped>
	body {
		font-size: 12px;
	}

	a {
		text-decoration: none;
	}

	input[type='text'] {
		border: solid 1px black;
		width: 80%;
	}

	textarea {
		border: solid 1px black;
		width: 1100px;
		height: 30px;
	}

	.tableEdit {
		border: solid 1px #B5D6E6;
		border-collapse: collapse;
		width: 100%;
		/*margin: 25px;*/
	}

		.tableEdit th {
			text-align: right;
			padding: 5px 8px;
			border: solid 1px #B5D6E6;
			width: 100px;
			background-color: #f4f4f4;
		}

		.tableEdit td {
			text-align: left;
			padding: 5px 8px;
			border: solid 1px #B5D6E6;
		}

</style>